if (self.CavalryLogger) { CavalryLogger.start_js(["4Jsiq"]); } __d("NotificationGenericBucket",["NotificationSeenState"],(function(a,b,c,d,e,f){"use strict";__p&&__p();a=function(){__p&&__p();function a(a){var b=this;this.$2=[];this.$3={};this.$4={};this.$7=function(a,c){a=b.$4[a];c=b.$4[c];return Number(c)-Number(a)};this.$1=a}var c=a.prototype;c.reset=function(){this.$2=[],this.$3={},this.$4={}};c.getType=function(){return this.$1.bucket_type};c.getTitle=function(){return this.$1.title};c.getSortedIDs=function(){return this.$2.slice()};c.insertIfEligible=function(a){var b=this.$5(a);if(!b.eligible)return b;this.$6(a);return{eligible:!0}};c.remove=function(a){if(!this.$3[a])return!1;delete this.$3[a];delete this.$4[a];a=this.$2.indexOf(a);a>-1&&this.$2.splice(a,1);return!0};c.$6=function(a){__p&&__p();var b=a.alert_id;if(this.$3[b])return!0;this.$2.push(b);this.$3[b]=!0;var c=this.$8(this.$1.sort_key_index);if(c>-1){a=a.sort_keys?a.sort_keys[c]:null;a&&(this.$4[b]=a,this.$9())}return!0};c.$9=function(){this.$2.sort(this.$7)};c.$5=function(a){__p&&__p();if(!this.$10(a))return{eligible:!1,type:"bucket",data:a.eligible_buckets};if(!this.$11(a))return{eligible:!1,type:"exp_time"};if(!this.$12(a))return{eligible:!1,type:"seen_filter"};if(!this.$13(a))return{eligible:!1,type:"max_count"};if(!this.$14(a))return{eligible:!1,type:"seen_evict",data:this.$15(a)};return!this.$16(a)?{eligible:!1,type:"read_evict"}:{eligible:!0}};c.$8=function(a){return Number.isInteger(a)?Number(a):-1};c.$10=function(a){return!a.eligible_buckets?!1:a.eligible_buckets.includes(this.getType())};c.$12=function(a){return b("NotificationSeenState").validateFilter(a.alert_id,this.$1.seen_filter)};c.$11=function(a){var b=this.$8(this.$1.min_to_expire);return b===-1?!0:Date.now()-a.creation_time=b:!1;e?(d!=null||g(0,5709),d.calls.push(j)):(i[f]==null&&(i[f]=[]),i[f].push(j),d==null&&p(a));return{remove:function(){__p&&__p();var b=h[f];if(b!=null){var c=b.calls.indexOf(j);c!==-1&&b.calls.splice(c,1);b.calls.length===0&&(b.transport&&b.transport.abandon(),delete h[f],i[f]!=null&&p(a))}c=i[f];if(c!=null){b=c.indexOf(j);b!==-1&&c.splice(b,1)}}}},handleResponseChunk:function(a,b){a=q(a);a.forEach(function(a){a(b)})},handleRequestCompleted:function(a){var c=b("objectValues")(h).find(function(b){return b&&b.clientRequestID===a});c||g(0,5710,a);n(a,c.endpointState)},handleRequestFailed:function(a,c){__p&&__p();var d=b("objectValues")(h).find(function(b){return b&&b.clientRequestID===a});d||g(0,5711,a);var e=d.endpointState.getHash(),f=h[e];if(!f||f.clientRequestID!==a)return;delete h[e];f.calls.forEach(function(a){a=a.onError;a&&a(new Error(c))});i[e]!=null&&p(d.endpointState)}};function q(a){__p&&__p();var c=Object.keys(h).find(function(b){b=h[b];return b&&b.clientRequestID===a}),d=c&&h[c];if(!d||!c)return[];d=d.calls;c=i[c];c&&(d=d.concat(c));return b("compactArray")(d.map(function(a){return a.onChunkResponse}))}function r(a,c){__p&&__p();var d=c.targetNumToLoad,e=c.endpointState;c=c.payloadPromise;if(h[a]!=null)return;var f=b("uniqueID")();d={calls:[{targetNumToLoad:d}],clientRequestID:f,endpointState:e};h[a]=d;c||g(0,5712);a=c.then(function(a){var b=q(f);b.forEach(function(b){b(a)})});b("promiseDone")(a["finally"](function(){n(f,e)}))}c=function(a){b("ifRequired")("NotificationEagerLoader",function(b){b=b.eagerlyLoadedData;b.hasData&&a===b.endpointState.getHash()&&r(a,b)})};var s=b("once")(c);e.exports=a}),null); __d("NotificationStore",["FBLogger","NotificationConstants","NotificationEndpointState","NotificationServerTransport","NotificationUpdates","createObjectBy","distinctArrayBy","flatMapArray","objectValues","sortBy"],(function(a,b,c,d,e,f){__p&&__p();var g={};function h(a,b,c){return a.page_info!=null&&b.classification==c.classification&&b.endpointControllerName===c.endpointControllerName&&b.readness==c.readness}function i(a,c){__p&&__p();var d={};b("NotificationEndpointState").getAllInstances(c.endpointControllerName).forEach(function(e){var f;h(a,e,c)?(e.graphQLPageInfo=a.page_info,f=a):a.payloadsource===b("NotificationConstants").PayloadSourceType.SYNC&&c.endpointControllerName==="WebNotificationsPayloadPagelet"&&e.classification==null&&e.readness==null?f=a:f=babelHelpers["extends"]({},a,{nodes:a.nodes?a.nodes.filter(function(a){return j(a,e)}):void 0});if(f.nodes&&f.nodes.length>0){f=k(e,f);f!=null&&f.forEach(function(a){d[a]=!0})}});b("NotificationUpdates").didUpdateNotifications(Object.keys(d))}function j(a,b){__p&&__p();var c=b.classification,d=b.notifications,e=b.order;b=b.readness;e=e.getAllResources();e.length===0;if(e.length>0){e=e[0];d=d.getResource(e);if(d.creation_time>=a.creation_time)return!1}if(c&&(!a.classifications||!a.classifications.includes(c)))return!1;return b&&b==="SEEN_AND_READ"!==(a.seen_state==="SEEN_AND_READ")?!1:!0}function k(a,b){var c=[],d={};b.nodes&&b.nodes.length>0&&b.nodes.forEach(function(b){var e=b.alert_id,f=a.notifications.getResource(e);(!f||f.creation_time0&&b("FBLogger")("notifications").warn("The range for this endpoint contained notification IDs for which we have no payload (Notification IDs: %s, Endpoint config: %s)",JSON.stringify(a),JSON.stringify(e.getConfig()))}});function m(){h.unsubscribe(k),j&&f.unsubscribe(j)}if(h.getUnavailableResources(k).length===0)return{remove:m};if(!l.canFetchMore(c)){h.forceRunCallbacks();return{remove:m}}var n=e.getHash();g[n]==null?g[n]=1:g[n]++;function o(){g[n]--,g[n]===0&&h.forceRunCallbacks()}function p(a){if(!(a&&a.nodes))return;b("NotificationUpdates").handleUpdate(b("NotificationConstants").PayloadSourceType.ENDPOINT,a,c.readness,c.classification);i(babelHelpers["extends"]({},a,{payloadsource:b("NotificationConstants").PayloadSourceType.ENDPOINT}),c)}function q(){g[n]--,g[n]===0&&h.forceRunCallbacks()}a=b("NotificationServerTransport").makeRequest(e,a,{onChunkResponse:p,onCompleted:q,onError:o});var r=a.remove;return{remove:function(){m(),r()}}},getNotification:function(a,c){c=c===void 0?{}:c;var d=c.classification,e=c.endpointControllerName;e=e===void 0?"WebNotificationsPayloadPagelet":e;c=c.readness;d=b("NotificationEndpointState").getInstance({classification:d,endpointControllerName:e,readness:c});e=d.notifications;return e.getResource(a)},getAllForAllEndpoints:function(){__p&&__p();var a=this,c=b("NotificationEndpointState").getAllInstances();c=b("flatMapArray")(c,function(c){c=a.getAll(c.getConfig());return b("objectValues")(c)});c=b("sortBy")(c,function(a){return a.creation_time});c=c.reverse();c=b("distinctArrayBy")(c,function(a){return a.alert_id});return b("createObjectBy")(c,function(a){return a.alert_id})},getAll:function(a){var c=b("NotificationEndpointState").getInstance(a),d=c.notifications;c=c.order;var e={};c.getAllResources().forEach(function(c){var f=d.getResource(c);f==null?b("FBLogger")("notifications").warn("The range for this endpoint contained a notification ID for which we have no payload (Notification ID: %s, Endpoint config: %s)",c,JSON.stringify(a)):e[c]=f});return e},getCount:function(a){a=b("NotificationEndpointState").getInstance(a);return a.order.getAllResources().length},canFetchMore:function(a){a=b("NotificationEndpointState").getInstance(a);a=a.graphQLPageInfo;return!a||!Object.prototype.hasOwnProperty.call(a,"has_next_page")||a.has_next_page},registerEndpoint:function(a){b("NotificationEndpointState").getInstance(a)}};l.registerEndpoint({endpointControllerName:"WebNotificationsPayloadPagelet"});e.exports=l}),null); __d("NotificationBucketStore",["Arbiter","JSLogger","NotificationBucketStoreManager","NotificationConstants","NotificationGenericBucket","NotificationsBucketList","NotificationStore","NotificationUpdates"],(function(a,b,c,d,e,f){"use strict";__p&&__p();a=function(){__p&&__p();function a(a,b){this.$1=[],this.$2={},this.$3=[],this.$4={},this.$5=b,this.$6=!1,this.$7=null,this.$8={},this.$6=!1,this.$9(a),this.$10()}var c=a.prototype;c.$9=function(a){__p&&__p();var c=this;if(this.$6)return;this.$6=!0;b("NotificationsBucketList").buckets.forEach(function(a){a.bucket_type=a.bucket_type.toUpperCase();a=new(b("NotificationGenericBucket"))(a);c.$3.push(a);c.$4[a.getType()]=a});this.$11(a,this.$5,!1)};c.$12=function(){this.$1=this.$3.map(function(a){return{ids:a.getSortedIDs(),title:a.getTitle()||"",bucketType:a.getType()}})};c.$13=function(a,c,d){return!d&&a===b("NotificationBucketStoreManager").getSkipBucketType()&&!c};c.$14=function(a,b,c){__p&&__p();var d=a.alert_id;this.$2[d]||(this.$2[d]=[]);var e=[];for(var f=0,g=this.$3.length;f